package testClasses.misc;

import gameAppLayer.enums.Constants;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;

import stars.enums.StarTypeData;

public class FileReadingTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		FileReadingTest test = new FileReadingTest();
		test.execute();
	}
	
	
	public void execute() {
		
		String path = Constants.dataPath + "//StarData.txt";
		
		String result = "NA";
		
		ArrayList<StarTypeData> starDataList = new ArrayList<StarTypeData>();
		
		
		try {
			FileReader fr = new FileReader(path);
			BufferedReader br = new BufferedReader(fr);
			
			result = br.readLine();			
			result = br.readLine();
			
			while (result!=null) {			
				
				String[] pieces = result.split("\t");
				StarTypeData starData = new StarTypeData(pieces[0]);				
				starData.setYoungProb(Double.parseDouble(pieces[1]));
				starData.setAverageProb(Double.parseDouble(pieces[2]));
				starData.setOldProb(Double.parseDouble(pieces[3]));
				starData.setMaxLuminance(Double.parseDouble(pieces[4]));
				starData.setMinLuminance(Double.parseDouble(pieces[5]));
				starData.setMaxTemp(Double.parseDouble(pieces[6]));
				starData.setMinTemp(Double.parseDouble(pieces[7]));
				starData.setMaxMass(Double.parseDouble(pieces[8]));
				starData.setMinMass(Double.parseDouble(pieces[9]));
				starData.setMaxRadius(Double.parseDouble(pieces[10]));
				starData.setMinRadius(Double.parseDouble(pieces[11]));
				starData.setMaxRotation(Double.parseDouble(pieces[12]));
				starData.setMinRotation(Double.parseDouble(pieces[13]));
				starData.setMaxMagField(Double.parseDouble(pieces[14]));
				starData.setMinMagField(Double.parseDouble(pieces[15]));
				starData.setBinaryProb(Double.parseDouble(pieces[16]));
				starData.setTrinaryProb(Double.parseDouble(pieces[17]));
				starData.setQuadProb(Double.parseDouble(pieces[18]));
				starData.setColor(pieces[19]);
				ArrayList<Integer> RGBColorVals = new ArrayList<Integer>();
				RGBColorVals.add(Integer.parseInt(pieces[20]));
				RGBColorVals.add(Integer.parseInt(pieces[21]));
				RGBColorVals.add(Integer.parseInt(pieces[22]));
				starData.setRGBColorVals(RGBColorVals);
				
				starDataList.add(starData);
				result = br.readLine();
			}
			
			br.close();
			
		}
		catch (Exception e) {
			System.out.println("IOException: " + e);
		}		
	}

}
